@extends('layouts.console_header')

@section('title', '充值退款记录')

@section('resources')
    @parent
    <style>
        nav{height: 50px;line-height: 50px;}
        nav a,nav span{margin-left: 20px;}
        nav input{margin-left: 20px;height: 28px;border: 1px solid #000;margin-top: 10px;}
        .display{text-align: center;background-color: #fff;border-collapse:collapse;}
        .display th{padding: 20px 0;}
        .display #tbody_content{border-top: 1px solid #000;border-bottom: 1px solid #000;font-size: 14px;}
        .display #tbody_content tr:nth-child(2n+1){border-bottom: 1px solid #ddd;background-color: #f9f9f9;}
        .display #tbody_content tr:nth-child(2n){border-bottom: 1px solid #ddd;}
        .display #tbody_content tr td{padding: 10px 0;}
        .display #tbody_content tr td:nth-child(1){background-color: #f1f1f1;}
        .user_list_search{overflow: hidden;margin: 10px 20px;}
        .user_list_search input{float: right;width: 200px;height: 30px;border: 1px solid #000;}
        .user_list_search .user_list_searchbtn{float: right;height: 30px;margin-left: 10px;width: 50px;background-color: #9955c6;color: #fff;border: none;}
        .user_list_pageouter{overflow: hidden;background-color: #fff;}
        .user_list_page{float: right;overflow: hidden;}
        .user_list_page a{float: left;width: 40px;height: 30px;line-height: 30px;text-align: center;}
        .user_list_page .show{background-color: #eee;border: 1px solid #ccc;}
        .consume_count span{margin: 10px 0 10px 20px;}
    </style>
@endsection

@section('content')
<section class="user_list">
    <div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
        <p class="fz_14 account_title fl" style="border: none;">
            <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>订单管理></span>
            <span class="co_violet">充值退款记录</span>
        </p>
        <a href="#" onclick="export_data()"><p class="fr tc back_btn">导出</p></a>
    </div>
    <nav>
        <a class="fl" href="/console/order/recharge/refund/list?cityid={{$cityid}}&type=today">今日</a>
        <a class="fl" href="/console/order/recharge/refund/list?cityid={{$cityid}}&type=yesterday">昨日</a>
        <a class="fl" href="/console/order/recharge/refund/list?cityid={{$cityid}}&type=week">本周</a>
        <a class="fl" href="/console/order/recharge/refund/list?cityid={{$cityid}}&type=thismonth">本月</a>
        <a class="fl" href="/console/order/recharge/refund/list?cityid={{$cityid}}&type=lastmonth">上月</a>
        <a class="fl" href="/console/order/recharge/refund/list?cityid={{$cityid}}&type=all">全部</a>
        <span class="fl">时段选择</span>
        <input class="fl" type="date" name="starttime" value="{{date('Y-m-d', strtotime($starttime))}}" onchange="select_date()">
        <span class="fl">至</span>
        <input class="fl" type="date" name="lasttime" value="{{date('Y-m-d', strtotime($lasttime))}}" onchange="select_date()">
    </nav>
    <p class="user_list_search">
        <input class="user_list_searchbtn" type="button" name="submit_search" value="搜索">
        <input type="text" name="search" value="{{$search}}" placeholder="搜索">
    </p>
    <p class="consume_count oh">
        <span class="fl">合计：{{$total}}笔退款</span>
        <span class="fl">退款金额：{{$moneytotal}}</span>
        <span class="fl">服务费金额：{{$feetotal}}</span>
        <span class="fl">实际退款金额：{{$actualmoneytotal}}</span>
    </p>
    <table class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>退款时间</th>
                <th>用户昵称</th>
                <th>用户账号</th>
                <th>退款金额(元)</th>
                <th>服务费(元)</th>
                <th>退款实际金额(元)</th>
                <th>退款前余额</th>
                <th>退款后余额</th>
                <th>备注</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>退款时间</th>
                <th>用户昵称</th>
                <th>用户账号</th>
                <th>退款金额(元)</th>
                <th>服务费(元)</th>
                <th>退款实际金额(元)</th>
                <th>退款前余额</th>
                <th>退款后余额</th>
                <th>备注</th>
            </tr>
        </tfoot>
        <tbody id="tbody_content">
        @foreach($lists as $list)
            <tr>
                <td>{{date('Y-m-d H:i', strtotime($list['created_at']))}}</td>
                <td>{{$list['nickname']}}</td>
                <td>{{$list['mobile']}}</td>
                <td>{{$list['money']}}</td>
                <td>{{$list['fee']}}</td>
                <td>{{$list['actualmoney']}}</td>
                <td>{{$list['startbalance']}}</td>
                <td>{{$list['lastbalance']}}</td>
                <td>{{$list['note']}}</td>
            </tr>
        @endforeach
        </tbody>
    </table>

    <div class="user_list_pageouter">
        <p class="user_list_page">
            <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page=1&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">首页</a>
            @if($lastpage <=5)
                @for($i=1; $i<=$lastpage; $i++)
                    @if($page == $i)
                        <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}" class="show">{{$i}}</a>
                    @else
                        <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$i}}</a>
                    @endif
                @endfor
            @else
                @if($page>2)
                    <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$page-2}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page-2}}</a>
                @endif
                @if($page>1)
                    <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$page-1}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page-1}}</a>
                @endif
                <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$page}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}" class="show">{{$page}}</a>
                @if(($page+5)<$lastpage)
                    <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$page+1}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+1}}</a>
                    <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$page+2}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+2}}</a>
                    <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$page+3}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+3}}</a>
                    <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$page+4}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+4}}</a>
                    <a href="">....</a>
                    <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$lastpage}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$lastpage}}</a>
                @else
                    @for($i=1; $i<=5;$i++)
                        @if($page+$i<=$lastpage)
                            <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$page+$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+$i}}</a>
                        @endif
                    @endfor
                @endif
            @endif
            <a href="/console/order/recharge/refund/list?cityid={{$cityid}}&page={{$lastpage}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">末页</a>
        </p>
    </div>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
        var cityid='{{$cityid}}';
        var starttime='{{$starttime}}';
        var lasttime='{{$lasttime}}';
        var str = window.location.href;
        if(str.indexOf("today") > 0){
            $("nav a").eq(0).css({"color": "#9955c6"});
        }else if(str.indexOf("yesterday") > 0){
            $("nav a").eq(1).css({"color": "#9955c6"});
        }else if(str.indexOf("week") > 0){
            $("nav a").eq(2).css({"color": "#9955c6"});
        }else if(str.indexOf("thismonth") > 0){
            $("nav a").eq(3).css({"color": "#9955c6"});
        }else if(str.indexOf("lastmonth") > 0){
            $("nav a").eq(4).css({"color": "#9955c6"});
        }else if(str.indexOf("all") > 0){
            $("nav a").eq(5).css({"color": "#9955c6"});
        }
//        function select_date() {
//            var startTime = $("input[name='starttime']").val();
//            var lastTime = $("input[name='lasttime']").val();
//            if(!startTime || !lastTime) {
//                alert('请选择开始时间和结束时间'); return;
//            }
//            window.location.href="/console/order/recharge/refund/list?cityid=" + cityid+"&starttime="+startTime+"&lasttime="+lastTime;
//        }
        function export_data() {
            var cityid = "{{$cityid}}";
            var startTime = $("input[name='starttime']").val();
            var lastTime = $("input[name='lasttime']").val();
            var search = $("input[name='search']").val();
            var start_date = new Date(startTime);
            var last_date = new Date(lastTime);
            var differ = last_date.getTime()-start_date.getTime();
            differ = parseInt(differ/(1000*60*60*24));
            if(!startTime || !lastTime) {
                alert('请选择开始时间和结束时间'); return;
            }
            if(differ > 30){
                $(".public_prompt").show();
                $(".public_prompt_mark").show();
                $(".public_prompt_name").html("警告");
                $(".public_prompt_ctn").html("您选择数据过大，请重新选择！");
                $(".public_prompt_mark").height($(window).height());
                $(".public_prompt .public_prompt_btn").click(function(){
                    $(".public_prompt").hide();
                    $(".public_prompt_mark").hide();
                });
                $(".public_prompt .prompt_close").click(function(){
                    $(".public_prompt").hide();
                    $(".public_prompt_mark").hide();
                });
            }else{
                window.open("/console/order/recharge/refund/list/export?cityid="+cityid+"&search="+search+"&starttime="+startTime+"&lasttime="+lastTime, '_blank');
            }
        }


        $(".user_list_searchbtn").click(function() {
            var cityid = "{{$cityid}}";
            var search=$("input[name='search']").val();
//        if(search == '') {
//            return;
//        }
            window.location.href = "/console/order/recharge/refund/list?cityid="+cityid+"&search="+search+"&now=" + Date.parse(new Date());
        });
    </script>
@endsection